[APAC] Keep vendor ACY on purchase invoice payables entry - #10168
[APAC] Keep vendor ACY on purchase invoice payables entry#10168Jose Antonio Garcia Garcia (Jose-agg) wants to merge 6 commits into
Conversation
Agentic PR Review - Round 1Recommendation: AcceptWhat this PR doesThis PR fixes the APAC purchase invoice path when Additional Reporting Currency and Vendor GST Amount (ACY) are enabled. It keeps the vendor-rate ACY on the payables G/L entry when the purchase invoice is in LCY, and it calculates Source Currency Amount from LCY instead of reusing ACY. The change is in HandleDtldAdjustment, before the payables G/L entry is initialized. In the vendor path, UseVendExchRate makes GLCalcAddCurrency keep the supplied TotalAmountAddCurr, so the detailed vendor buffer ACY now reaches the balancing entry instead of being posted as a residual entry. The source-currency-equals-ACY branch is unchanged, and the new test checks the expense ACY, payables ACY, source currency amount, total balances, and absence of residual G/L entries. SuggestionsNone. Risk assessment and necessityRisk: This is a financial posting path, so the main risk is wrong G/L amounts for APAC purchase documents with additional reporting currency. The code change is narrow: one InitGLEntry call now passes the already calculated vendor ACY and an independently calculated source currency amount. There are no schema, public API, or event signature changes. Necessity: The linked bug and PR evidence describe a real live-site case where the payables ACY was left at zero and a residual gains/losses entry was created. The fix targets that root cause without restoring the removed global source-currency state, and the added test covers the reported posting result.
|
3f72dc7
Agentic PR Review - Round 2Recommendation: Request ChangesWhat this PR doesThis PR fixes the APAC purchase invoice posting path so a blank-currency invoice with vendor ACY keeps the vendor-rate ACY on the payables entry instead of creating a residual gain or loss entry. The main scenario and the new regression test match the linked bug, but the new helper does not fully mirror the Status of previous suggestionsNo previous suggestions were recorded in round 1. New observations (commits since round 1)S1 - Add the missing posting rule guard S2 - Save setup before changing the flag Risk assessment and necessityRisk: The affected code is APAC G/L posting for purchase documents with Additional Reporting Currency and vendor ACY. A wrong branch here can persist wrong source currency or ACY amounts on ledger entries. There is no schema or event signature change, and no BaseApp event dependency in this diff. Necessity: The bug is valid and important because the current posting can move the vendor ACY to a residual gains or losses entry. The scope is targeted, but the helper needs the same guard as the calculation it mirrors before this financial posting change is safe.
|
What & why
I reproduced this issue in AU with an Additional Reporting Currency enabled,
Enable Vendor GST Amount (ACY)turned on, a blank purchase invoice currency, and a nonzeroVendor Exchange Rate (ACY).The same scenario does not reproduce in W1 because W1 keeps the detailed CV buffer amount as the document/source amount and calculates ACY independently from LCY. APAC uses that buffer differently: it stores the vendor-calculated ACY so the vendor exchange rate is preserved.
The source-currency change from PR 241506 applied the W1 initialization pattern to APAC as well. In this APAC path, that passed zero as the balancing entry's ACY and reused the actual ACY as Source Currency Amount. The posting therefore left the full ACY amount unbalanced and created a separate residual entry.
This change keeps the already-calculated vendor ACY in
Additional-Currency Amountand calculates Source Currency Amount independently from LCY. It does not restore the globalTotalSrcCurrAmountstate removed by PR 241506.Linked work
Fixes AB#641827
How I validated this
What I tested and the outcome
PurchaseInvoiceWithVendorACYPostsACYOnPayablesEntry; the test passes.PurchaseVendorExchangeRateIsUsedForAdditionalCurrencyAmountCalculation; the test passes.1,477.00and vendor ACY rate1.2726.1,477.00, ACY1,879.63.-1,477.00, ACY-1,879.63.Residual caused by roundingentry was created.Risk & compatibility
The change is limited to the APAC layer and does not change W1 behavior, table schemas, or stored data.
The existing branch where Source Currency Code equals ACY remains unchanged. For other APAC entries, source currency and ACY are now calculated independently rather than using the same amount for both fields.